package com.lgd.tools;

import java.util.ArrayList;

/**
 * Created by 299174105 on 2017/7/17.
 */
public class Efficient {
    public static void main(String[] args) {
        /*

        //随机数生成效率
        long start = System.currentTimeMillis();
        System.out.println(UUID.randomUUID().toString());
        long end = System.currentTimeMillis();
        System.out.println(end-start);
        long s = System.currentTimeMillis();
        byte[] bytes = new byte[16];
        ThreadLocalRandom.current().nextBytes(bytes);
        System.out.println(Arrays.toString(bytes));
        long e = System.currentTimeMillis();
        System.out.println(e-s);

        //打印当前项目的绝对路径
        System.out.println(System.getProperty("user.dir"));

        //空list的iterator问题
        ArrayList objects = getList(4);
        if (objects ==null) objects = new ArrayList();
        objects.forEach(System.out::println);

        //外部读取配置文件
        String property = System.getProperty("user.dir");
        String filePath = property+"/config/config.properties";
        Properties properties =new Properties();
        try {
            InputStream    in = new BufferedInputStream(new FileInputStream(filePath));
            properties.load(in);
            in.close();
            System.out.println(properties.getProperty("test"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        */
        //异常处理
      /*  try {
            int a =1;
            int b =2;
            int c =a/b;
            System.out.println(c);
        } catch (ArithmeticException e) {
            e.printStackTrace();//打印堆栈信息
            System.out.println("除数不能为零!");
        }*/


    }
    private static ArrayList getList(int in){
        if (in ==3) {
            return null;
        }else {
            ArrayList arrayList = new ArrayList();
            arrayList.add(1);
            arrayList.add(2);
            return arrayList;
        }
    }
}
